package com.cmy.demo02;

import com.cmy.demo01.UserService;
import com.cmy.demo01.UserServiceImpl;

public class Client {
    public static void main(String[] args) {
        //真实角色
        UserServiceImpl userService = new UserServiceImpl();
        //代理角色,使用ProxyInvocationHandler动态创建
        ProxyInvocationHandler pih = new ProxyInvocationHandler();
        pih.setTarget(userService);//设置要代理的对象

        //动态生成代理类,本质通过反射得到
        UserService proxy = (UserService) pih.getProxy();

        proxy.add();
    }
}

    